home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / libgimp / gimppaths_pdb.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-26  |  15.1 KB  |  509 lines

  1. /* LIBGIMP - The GIMP Library
  2.  * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
  3.  *
  4.  * gimppaths_pdb.c
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Lesser General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * Lesser General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Lesser General Public
  17.  * License along with this library; if not, write to the
  18.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.  * Boston, MA 02111-1307, USA.
  20.  */
  21.  
  22. /* NOTE: This file is autogenerated by pdbgen.pl */
  23.  
  24. #include <string.h>
  25.  
  26. #include "gimp.h"
  27.  
  28. /**
  29.  * gimp_path_list:
  30.  * @image_ID: The ID of the image to list the paths from.
  31.  * @num_paths: The number of paths returned.
  32.  *
  33.  * List the paths associated with the passed image.
  34.  *
  35.  * List the paths associated with the passed image.
  36.  *
  37.  * Returns: List of the paths belonging to this image.
  38.  */
  39. gchar **
  40. gimp_path_list (gint32  image_ID,
  41.         gint   *num_paths)
  42. {
  43.   GimpParam *return_vals;
  44.   gint nreturn_vals;
  45.   gchar **path_list = NULL;
  46.   gint i;
  47.  
  48.   return_vals = gimp_run_procedure ("gimp_path_list",
  49.                     &nreturn_vals,
  50.                     GIMP_PDB_IMAGE, image_ID,
  51.                     GIMP_PDB_END);
  52.  
  53.   *num_paths = 0;
  54.  
  55.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  56.     {
  57.       *num_paths = return_vals[1].data.d_int32;
  58.       path_list = g_new (gchar *, *num_paths);
  59.       for (i = 0; i < *num_paths; i++)
  60.     path_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
  61.     }
  62.  
  63.   gimp_destroy_params (return_vals, nreturn_vals);
  64.  
  65.   return path_list;
  66. }
  67.  
  68. /**
  69.  * gimp_path_get_points:
  70.  * @image_ID: The ID of the image to list the paths from.
  71.  * @pathname: the name of the path whose points should be listed.
  72.  * @path_closed: Return if the path is closed. {0=path open, 1= path closed}.
  73.  * @num_path_point_details: The number of points returned. Each point is made up of (x,y,pnt_type) of floats.
  74.  * @points_pairs: The points in the path represented as 3 floats. The first is the x pos, next is the y pos, last is the type of the pnt. The type field is dependant on the path type. For beziers (type 1 paths) the type can either be {1.0= BEZIER_ANCHOR, 2.0= BEZIER_CONTROL}. Note all points are returned in pixel resolution.
  75.  *
  76.  * List the points associated with the named path.
  77.  *
  78.  * List the points associated with the named path.
  79.  *
  80.  * Returns: The type of the path. Currently only one type (1 = Bezier) is supported.
  81.  */
  82. gint
  83. gimp_path_get_points (gint32    image_ID,
  84.               gchar    *pathname,
  85.               gint     *path_closed,
  86.               gint     *num_path_point_details,
  87.               gdouble **points_pairs)
  88. {
  89.   GimpParam *return_vals;
  90.   gint nreturn_vals;
  91.   gint path_type = 0;
  92.  
  93.   return_vals = gimp_run_procedure ("gimp_path_get_points",
  94.                     &nreturn_vals,
  95.                     GIMP_PDB_IMAGE, image_ID,
  96.                     GIMP_PDB_STRING, pathname,
  97.                     GIMP_PDB_END);
  98.  
  99.   *num_path_point_details = 0;
  100.  
  101.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  102.     {
  103.       path_type = return_vals[1].data.d_int32;
  104.       *path_closed = return_vals[2].data.d_int32;
  105.       *num_path_point_details = return_vals[3].data.d_int32;
  106.       *points_pairs = g_new (gdouble, *num_path_point_details);
  107.       memcpy (*points_pairs, return_vals[4].data.d_floatarray,
  108.           *num_path_point_details * sizeof (gdouble));
  109.     }
  110.  
  111.   gimp_destroy_params (return_vals, nreturn_vals);
  112.  
  113.   return path_type;
  114. }
  115.  
  116. /**
  117.  * gimp_path_get_current:
  118.  * @image_ID: The ID of the image to get the current paths from.
  119.  *
  120.  * The name of the current path. Error if no paths.
  121.  *
  122.  * The name of the current path. Error if no paths.
  123.  *
  124.  * Returns: The name of the current path.
  125.  */
  126. gchar *
  127. gimp_path_get_current (gint32 image_ID)
  128. {
  129.   GimpParam *return_vals;
  130.   gint nreturn_vals;
  131.   gchar *current_path_name = NULL;
  132.  
  133.   return_vals = gimp_run_procedure ("gimp_path_get_current",
  134.                     &nreturn_vals,
  135.                     GIMP_PDB_IMAGE, image_ID,
  136.                     GIMP_PDB_END);
  137.  
  138.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  139.     current_path_name = g_strdup (return_vals[1].data.d_string);
  140.  
  141.   gimp_destroy_params (return_vals, nreturn_vals);
  142.  
  143.   return current_path_name;
  144. }
  145.  
  146. /**
  147.  * gimp_path_set_current:
  148.  * @image_ID: The ID of the image to list set the paths in.
  149.  * @set_current_path_name: The name of the path to set the current path to.
  150.  *
  151.  * List the paths associated with the passed image.
  152.  *
  153.  * List the paths associated with the passed image.
  154.  *
  155.  * Returns: TRUE on success.
  156.  */
  157. gboolean
  158. gimp_path_set_current (gint32  image_ID,
  159.                gchar  *set_current_path_name)
  160. {
  161.   GimpParam *return_vals;
  162.   gint nreturn_vals;
  163.   gboolean success = TRUE;
  164.  
  165.   return_vals = gimp_run_procedure ("gimp_path_set_current",
  166.                     &nreturn_vals,
  167.                     GIMP_PDB_IMAGE, image_ID,
  168.                     GIMP_PDB_STRING, set_current_path_name,
  169.                     GIMP_PDB_END);
  170.  
  171.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  172.  
  173.   gimp_destroy_params (return_vals, nreturn_vals);
  174.  
  175.   return success;
  176. }
  177.  
  178. /**
  179.  * gimp_path_set_points:
  180.  * @image_ID: The ID of the image to set the paths in.
  181.  * @pathname: The name of the path to create (if it exists then a unique name will be created - query the list of paths if you want to make sure that the name of the path you create is unique. This will be set as the current path.
  182.  * @ptype: The type of the path. Currently only one type (1 = Bezier) is supported.
  183.  * @num_path_points: The number of points in the path. Each point is made up of (x,y,type) of floats. Currently only the creation of bezier curves is allowed. The type parameter must be set to (1) to indicate a BEZIER type curve. For BEZIERS. Note the that points must be given in the following order... ACCACCAC ... If the path is not closed the last control point is missed off. Points consist of three control points (control/anchor/control) so for a curve that is not closed there must be at least two points passed (2 x,y pairs). If num_path_pnts % 3 = 0 then the path is assumed to be closed and the points are ACCACCACCACC.
  184.  * @points_pairs: The points in the path represented as 3 floats. The first is the x pos, next is the y pos, last is the type of the pnt. The type field is dependant on the path type. For beziers (type 1 paths) the type can either be {1.0= BEZIER_ANCHOR, 2.0= BEZIER_CONTROL}. Note all points are returned in pixel resolution.
  185.  *
  186.  * Set the points associated with the named path.
  187.  *
  188.  * Set the points associated with the named path.
  189.  *
  190.  * Returns: TRUE on success.
  191.  */
  192. gboolean
  193. gimp_path_set_points (gint32   image_ID,
  194.               gchar   *pathname,
  195.               gint     ptype,
  196.               gint     num_path_points,
  197.               gdouble *points_pairs)
  198. {
  199.   GimpParam *return_vals;
  200.   gint nreturn_vals;
  201.   gboolean success = TRUE;
  202.  
  203.   return_vals = gimp_run_procedure ("gimp_path_set_points",
  204.                     &nreturn_vals,
  205.                     GIMP_PDB_IMAGE, image_ID,
  206.                     GIMP_PDB_STRING, pathname,
  207.                     GIMP_PDB_INT32, ptype,
  208.                     GIMP_PDB_INT32, num_path_points,
  209.                     GIMP_PDB_FLOATARRAY, points_pairs,
  210.                     GIMP_PDB_END);
  211.  
  212.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  213.  
  214.   gimp_destroy_params (return_vals, nreturn_vals);
  215.  
  216.   return success;
  217. }
  218.  
  219. /**
  220.  * gimp_path_stroke_current:
  221.  * @image_ID: The ID of the image which contains the path to stroke.
  222.  *
  223.  * Stroke the current path in the passed image.
  224.  *
  225.  * Stroke the current path in the passed image.
  226.  *
  227.  * Returns: TRUE on success.
  228.  */
  229. gboolean
  230. gimp_path_stroke_current (gint32 image_ID)
  231. {
  232.   GimpParam *return_vals;
  233.   gint nreturn_vals;
  234.   gboolean success = TRUE;
  235.  
  236.   return_vals = gimp_run_procedure ("gimp_path_stroke_current",
  237.                     &nreturn_vals,
  238.                     GIMP_PDB_IMAGE, image_ID,
  239.                     GIMP_PDB_END);
  240.  
  241.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  242.  
  243.   gimp_destroy_params (return_vals, nreturn_vals);
  244.  
  245.   return success;
  246. }
  247.  
  248. /**
  249.  * gimp_path_get_point_at_dist:
  250.  * @image_ID: The ID of the image the paths belongs to.
  251.  * @distance: The distance along the path.
  252.  * @y_point: The y position of the point.
  253.  * @gradient: The gradient at the specified point.
  254.  *
  255.  * Get point on a path at a specified distance along the path.
  256.  *
  257.  * This will return the x,y position of a point at a given distance
  258.  * along the bezier curve. The distance will the obtained by first
  259.  * digitizing the curve internally an then walking along the curve. For
  260.  * a closed curve the start of the path is the first point on the path
  261.  * that was created. This might not be obvious. Note the current path
  262.  * is used.
  263.  *
  264.  * Returns: The x position of the point.
  265.  */
  266. gint
  267. gimp_path_get_point_at_dist (gint32   image_ID,
  268.                  gdouble  distance,
  269.                  gint    *y_point,
  270.                  gdouble *gradient)
  271. {
  272.   GimpParam *return_vals;
  273.   gint nreturn_vals;
  274.   gint x_point = 0;
  275.  
  276.   return_vals = gimp_run_procedure ("gimp_path_get_point_at_dist",
  277.                     &nreturn_vals,
  278.                     GIMP_PDB_IMAGE, image_ID,
  279.                     GIMP_PDB_FLOAT, distance,
  280.                     GIMP_PDB_END);
  281.  
  282.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  283.     {
  284.       x_point = return_vals[1].data.d_int32;
  285.       *y_point = return_vals[2].data.d_int32;
  286.       *gradient = return_vals[3].data.d_float;
  287.     }
  288.  
  289.   gimp_destroy_params (return_vals, nreturn_vals);
  290.  
  291.   return x_point;
  292. }
  293.  
  294. /**
  295.  * gimp_path_get_tattoo:
  296.  * @image_ID: The image.
  297.  * @pathname: the name of the path whose tattoo should be obtained.
  298.  *
  299.  * Returns the tattoo associated with the name path.
  300.  *
  301.  * This procedure returns the tattoo associated with the specified
  302.  * path. A tattoo is a unique and permanent identifier attached to a
  303.  * path that can be used to uniquely identify a path within an image
  304.  * even between sessions.
  305.  *
  306.  * Returns: The tattoo associated with the name path.
  307.  */
  308. gint
  309. gimp_path_get_tattoo (gint32  image_ID,
  310.               gchar  *pathname)
  311. {
  312.   GimpParam *return_vals;
  313.   gint nreturn_vals;
  314.   gint tattoo = 0;
  315.  
  316.   return_vals = gimp_run_procedure ("gimp_path_get_tattoo",
  317.                     &nreturn_vals,
  318.                     GIMP_PDB_IMAGE, image_ID,
  319.                     GIMP_PDB_STRING, pathname,
  320.                     GIMP_PDB_END);
  321.  
  322.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  323.     tattoo = return_vals[1].data.d_int32;
  324.  
  325.   gimp_destroy_params (return_vals, nreturn_vals);
  326.  
  327.   return tattoo;
  328. }
  329.  
  330. /**
  331.  * gimp_get_path_by_tattoo:
  332.  * @image_ID: The image.
  333.  * @tattoo: The tattoo of the required path.
  334.  *
  335.  * Return the name of the path with the given tattoo.
  336.  *
  337.  * The procedure returns the name of the path in the specified image
  338.  * which has the passed tattoo. The tattoos are unique within the image
  339.  * and will be preserved across sessions and through renaming of the
  340.  * path. An error is returned if no path woth the specified tattoo can
  341.  * be found.
  342.  *
  343.  * Returns: The name of the path with the specified tattoo.
  344.  */
  345. gchar *
  346. gimp_get_path_by_tattoo (gint32 image_ID,
  347.              gint   tattoo)
  348. {
  349.   GimpParam *return_vals;
  350.   gint nreturn_vals;
  351.   gchar *path_name = NULL;
  352.  
  353.   return_vals = gimp_run_procedure ("gimp_get_path_by_tattoo",
  354.                     &nreturn_vals,
  355.                     GIMP_PDB_IMAGE, image_ID,
  356.                     GIMP_PDB_INT32, tattoo,
  357.                     GIMP_PDB_END);
  358.  
  359.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  360.     path_name = g_strdup (return_vals[1].data.d_string);
  361.  
  362.   gimp_destroy_params (return_vals, nreturn_vals);
  363.  
  364.   return path_name;
  365. }
  366.  
  367. /**
  368.  * gimp_path_delete:
  369.  * @image_ID: The ID of the image to list delete the paths from.
  370.  * @path_name_to_del: The name of the path to delete.
  371.  *
  372.  * Delete the named paths associated with the passed image.
  373.  *
  374.  * Delete the named path.
  375.  *
  376.  * Returns: TRUE on success.
  377.  */
  378. gboolean
  379. gimp_path_delete (gint32  image_ID,
  380.           gchar  *path_name_to_del)
  381. {
  382.   GimpParam *return_vals;
  383.   gint nreturn_vals;
  384.   gboolean success = TRUE;
  385.  
  386.   return_vals = gimp_run_procedure ("gimp_path_delete",
  387.                     &nreturn_vals,
  388.                     GIMP_PDB_IMAGE, image_ID,
  389.                     GIMP_PDB_STRING, path_name_to_del,
  390.                     GIMP_PDB_END);
  391.  
  392.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  393.  
  394.   gimp_destroy_params (return_vals, nreturn_vals);
  395.  
  396.   return success;
  397. }
  398.  
  399. /**
  400.  * gimp_path_get_locked:
  401.  * @image_ID: The image.
  402.  * @pathname: the name of the path whose locked status should be obtained.
  403.  *
  404.  * Returns the locked status associated with the name path.
  405.  *
  406.  * This procedure returns the lock status associated with the specified
  407.  * path. A path can be \"locked\" which means that the transformation
  408.  * tool operations will also apply to the path.
  409.  *
  410.  * Returns: The lock status associated with the name path. 0 returned if the path is not locked. 1 is returned if the path is locked.
  411.  */
  412. gint
  413. gimp_path_get_locked (gint32  image_ID,
  414.               gchar  *pathname)
  415. {
  416.   GimpParam *return_vals;
  417.   gint nreturn_vals;
  418.   gint lockstatus = 0;
  419.  
  420.   return_vals = gimp_run_procedure ("gimp_path_get_locked",
  421.                     &nreturn_vals,
  422.                     GIMP_PDB_IMAGE, image_ID,
  423.                     GIMP_PDB_STRING, pathname,
  424.                     GIMP_PDB_END);
  425.  
  426.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  427.     lockstatus = return_vals[1].data.d_int32;
  428.  
  429.   gimp_destroy_params (return_vals, nreturn_vals);
  430.  
  431.   return lockstatus;
  432. }
  433.  
  434. /**
  435.  * gimp_path_set_locked:
  436.  * @image_ID: The image.
  437.  * @pathname: the name of the path whose locked status should be set.
  438.  * @lockstatus: The lock status associated with the name path. 0 if the path is not locked. 1 if the path is to be locked.
  439.  *
  440.  * Set the locked status associated with the name path.
  441.  *
  442.  * This procedure sets the lock status associated with the specified
  443.  * path. A path can be \"locked\" which means that the transformation
  444.  * tool operations will also apply to the path.
  445.  *
  446.  * Returns: TRUE on success.
  447.  */
  448. gboolean
  449. gimp_path_set_locked (gint32  image_ID,
  450.               gchar  *pathname,
  451.               gint    lockstatus)
  452. {
  453.   GimpParam *return_vals;
  454.   gint nreturn_vals;
  455.   gboolean success = TRUE;
  456.  
  457.   return_vals = gimp_run_procedure ("gimp_path_set_locked",
  458.                     &nreturn_vals,
  459.                     GIMP_PDB_IMAGE, image_ID,
  460.                     GIMP_PDB_STRING, pathname,
  461.                     GIMP_PDB_INT32, lockstatus,
  462.                     GIMP_PDB_END);
  463.  
  464.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  465.  
  466.   gimp_destroy_params (return_vals, nreturn_vals);
  467.  
  468.   return success;
  469. }
  470.  
  471. /**
  472.  * gimp_path_set_tattoo:
  473.  * @image_ID: The image.
  474.  * @pathname: the name of the path whose tattoo should be set.
  475.  * @tattovalue: The tattoo associated with the name path. Only values returned from 'path_get_tattoo' should be used here.
  476.  *
  477.  * Sets the tattoo associated with the name path.
  478.  *
  479.  * This procedure sets the tattoo associated with the specified path. A
  480.  * tattoo is a unique and permenant identifier attached to a path that
  481.  * can be used to uniquely identify a path within an image even between
  482.  * sessions. Note that the value passed to this function must have been
  483.  * obtained from a previous call to path_get_tattoo.
  484.  *
  485.  * Returns: TRUE on success.
  486.  */
  487. gboolean
  488. gimp_path_set_tattoo (gint32  image_ID,
  489.               gchar  *pathname,
  490.               gint    tattovalue)
  491. {
  492.   GimpParam *return_vals;
  493.   gint nreturn_vals;
  494.   gboolean success = TRUE;
  495.  
  496.   return_vals = gimp_run_procedure ("gimp_path_set_tattoo",
  497.                     &nreturn_vals,
  498.                     GIMP_PDB_IMAGE, image_ID,
  499.                     GIMP_PDB_STRING, pathname,
  500.                     GIMP_PDB_INT32, tattovalue,
  501.                     GIMP_PDB_END);
  502.  
  503.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  504.  
  505.   gimp_destroy_params (return_vals, nreturn_vals);
  506.  
  507.   return success;
  508. }
  509.